<template>
  <div class="app-container overflow_yAuto">
    <div>
      <div slot="header" class="clearfix job-tab-header">
        <span class="span-title">代理人管理</span>
      </div>
      <div>
        <div class=" select-container" style="margin-top:-15px">
          <el-row class="">
            <el-col class="">
              <el-form ref="form"  label-position='right' size="small" :inline="true" label-width="110px">
                <el-col :span="5" >
                  <el-form-item label="" prop="subsys_name" size='small'  style="margin:12px 0px;">
                      <el-input
                        size="small"
                        style="width: 200px;"
                        class="filter-item"
                        placeholder="输入代理人"
                        clearable
                        v-model="postList.options[0].value"
                        prefix-icon="el-icon-search"
                        ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="5" >
                  <el-form-item label="" prop="en_subsys_name" size='small'  style="margin:12px 1px;">
                      <el-input
                        size="small"
                        style="width: 200px;"
                        class="filter-item"
                        placeholder="输入被代理人"
                        clearable
                        v-model="postList.options[1].value"
                        prefix-icon="el-icon-search"
                      ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="4" style="text-align: left;">
                  <el-button size="small" style="height:30px;padding-top:0px;line-height:30px;margin:12px 0px;" type="success" icon="el-icon-edit" @click="fetchData('find')">查 询</el-button>
                  <el-button size="small" style="height:30px;padding-top:0px;line-height:30px;" type="danger" icon="el-icon-circle-close-outline" @click="handleReset">重 置</el-button>
                </el-col>
              </el-form>
            </el-col>
          </el-row>
        </div>
      </div>
    </div>
      <div>
        <el-table
          :key='tableKey'
          :data="list.forms"
           v-loading="listLoading"
          element-loading-text="给我一点时间"
          size="small"
          stripe
          height="280px"
          style="width: 100%;border:#eeeeee"
          highlight-current-row>
          <el-table-column
            align="center"
            type="index"
            width="80"
            label="序号"
          >
            <template slot-scope="scope">
            <span>{{scope.$index + (serialNumber - 1) * postList.pageSize + 1}}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            label="代理人"
            prop="agentUname"
          ></el-table-column>
          <el-table-column
            align="center"
            label="代理人部门"
            prop="orgName"
          >
          </el-table-column>

          <el-table-column
            align="center"
            label="被代理人"
            prop="uname"
          >
          </el-table-column>
          <el-table-column
            align="center"
            label="被代理人部门"
            prop="agentOrgName"
          >
          </el-table-column>
          <el-table-column
            align="center"
            label="代理状态"
            prop="agetnStatus"
          >
          </el-table-column>
          <el-table-column
            align="center"
            label="开始时间"
            prop="startTime"
          >
          </el-table-column>
          <el-table-column
            align="center"
            label="结束时间"
            prop="endTime"
          >
          </el-table-column>
        </el-table>
        <div class="pagination-container">
          <el-pagination
            layout="total, sizes, prev, pager, next, jumper"
            :page-size = "postList.pageSize"
            :total="this.list.totalCount"
            :current-page="postList.page"
            :page-sizes="[10,20,30, 50]"
            @current-change="current_change"
            @size-change="handleSizeChange"
          >
          </el-pagination>
        </div>
      </div>
    </div>
</template>

<script>
import '@/styles/newstyle.scss'
import {
  selectAgent
} from '@/api/systemManage/selectAgent'
export default {
  data() {
    return {
      dappendVisible: false,
      updateVisible: false,
      tableKey: 0,
      list: {},
      postList: {
        page: 1,
        pageSize: 10,
        orderBy:'id',
        desc: true,
        options:[{
          field: 'uname',
          filter: 'LIKE',
          value: ''
        },{
          field: 'agentUname',
          filter: 'LIKE',
          value: ''
      }]
      },
      total: null,
      listLoading: false,
      serialNumber:1
    }
  },
  // 画面刚进入method
  created() {
    this.fetchData()
  },
  methods: {
    fetchData(flag) {
      this.listLoading = true
      if (flag == 'find') {
        this.postList.page = 1
        this.serialNumber = 1
        this.total = 0
      }
      selectAgent(this.postList).then(res => {
        this.list = res.data.data
        this.listLoading = false
      }).catch((err) => {
        console.log(err)
      })
    },
    current_change(currentPage) { // 通过分页获取数据
      this.serialNumber =currentPage
      this.postList.page = currentPage
      this.fetchData()
    },
    // 翻页器使用
    handleSizeChange(val) {
      this.postList.pageSize = val
      this.fetchData()
    },
    handleReset() {
      this.postList.options[0].value = ''
      this.postList.options[1].value = ''
      this.list.records = null
      this.postList.pageSize = 10
      this.serialNumber = 1
      this.postList.page = 1
      this.total = 0
      this.fetchData()
    }
  }
}
</script>

<style scoped>
  .container{
    color: #3b96f3;
    background: #fff;
    padding: 20px;
    height: 100%;
    overflow-y: auto;
  }
  .select-container{
    padding: 10px 10px;
    margin-bottom: 10px;
    border-radius: 4px;
    border: 1px solid #eeeeee;
  }
  .list-container{
    margin-top:30px;
    padding:0 10px 10px 10px;
    border:1px solid#eeeeee;
    border-radius: 4px;
  }
  .data-contant{
    background-color: rgba(0,0,0,.035);
    padding: 30px 10px 20px;
  }
  .data-detail{
    font-size: 14px;
    padding:20px 0;
    text-align: center;
  }
  .data-title{
    font-size: 14px;
    padding:10px 0;
    text-align: center;
  }
  .data-title div{
    font-size: 14px;
    padding:5px 0;
  }
  .filter{
    padding: 10px 5px;
    border-bottom: 2px solid#eeeeee;
  }
  .list-container{
  }
  .bold{
    font-weight: bold;
  }
</style>
